<?php
class system_models_File extends Zend_Db_Table_Abstract {
    protected $_name = "file";
    protected $_primary = "FileID";
    protected $_primary_name;
    public function __construct()
    {
        parent::__construct();
        $this->_primary_name = $this->_primary;
    }
	
    public function getAllFileByRecordId($arrRecordInfo) {
		$query = "SELECT * FROM $this->_name";
		$query .= " Where ".$this->getAdapter()->quoteInto("RecordID = ?",$arrRecordInfo[0]);
		$query .= $this->getAdapter()->quoteInto(" And TableName = ?",$arrRecordInfo[1]);
		$query .= $this->getAdapter()->quoteInto(" And RecordType = ?",$arrRecordInfo[2]);
        $data = $this->getAdapter()->fetchAll($query);
        return $data;
    }

	public function getFileView($arrFileInfo) {
		$query = "SELECT * FROM $this->_name";
		$query .= " Where ".$this->getAdapter()->quoteInto("FileID = ?",$arrFileInfo[0]);
		$query .= $this->getAdapter()->quoteInto(" And RecordID = ?",$arrFileInfo[1]);
		$query .= $this->getAdapter()->quoteInto(" And TableName = ?",$arrFileInfo[2]);
		$query .= $this->getAdapter()->quoteInto(" And RecordType = ?",$arrFileInfo[3]);
        $data = $this->getAdapter()->fetchRow($query);
        return $data;
    }
	
    public function deleteRows($listId){
        $aListID = explode(',', $listId);
        $where = $this->getAdapter()->quoteInto("$this->_primary_name IN (?)", $aListID);
        return $this->delete($where);
    }
}
